#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct CAR{
    int d;
    int v;
    int a;
}car[N];
int s[N],c[N];
int n,m,L,V;
vector<int>ss[N];
bool add(int i,int j){
    int t=0,w=car[i].d,v=car[i].v;
    bool f=true;
    if(car[i].a==0)return car[i].d>V;
    if(w>s[j])f=false;
    while(w<=s[j]&&v>0){
        w+=v;
        v+=car[i].a;
    }
    if(v<=0)f=false;
    v=car[i].v;
    double xx=sqrt(v*v+2*car[i].a*(s[j]-car[i].d));
    if(xx<=V)f=false;
    return f;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    for(int i=0;i<T;i++){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int j=0;j<n;j++)scanf("%d%d%d",&car[j].d,&car[j].v,&car[j].a);
        for(int j=0;j<m;j++){
            scanf("%d",&s[j]);
        }
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                if(add(j,k))ss[k].push_back(j),c[j]++;
            }
        }
        int tt=m,num=0;
        for(int j=0;j<n;j++){
            if(c[j])num++;
        }
        for(int j=0;j<m;j++){
            bool f=false;
            for(int k=0;k<ss[j].size();k++){
                if(c[ss[j][k]]==1){
                    f=true;
                    break;
                }
            }
            if(f)tt--;
            else for(int k=0;k<ss[j].size();k++)c[ss[j][k]]--;
        }
        printf("%d %d\n",num,tt);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
/*AKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOI
AKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOI
AKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOI
AKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOIAKIOI
*/